#include<iostream>
#include<pthread.h>


namespace Mutex
{
    class myMutex
    {
        public:
            myMutex operator =(const myMutex& tmp)=delete;
            myMutex(myMutex& tmp)=delete;
            myMutex()
            {
                int n = pthread_mutex_init(&_lock,nullptr);
                (void)n;
            }
            void Lcok()
            {
                pthread_mutex_lock(&_lock);
            }
            void Unlock()
            {
                pthread_mutex_unlock(&_lock);
            }
            ~myMutex()
            {
                pthread_mutex_destroy(&_lock);
            }
        private:
        pthread_mutex_t _lock;
    };

    class MutexGuard
    {
        public:
        MutexGuard(myMutex& mux):tmp(mux)
        {
            tmp.Lcok();
        }
        ~MutexGuard()
        {
            tmp.Unlock();
        }

        private:
        myMutex& tmp;
    };


}